<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>记事本</title>
</head>
    <style>
        .write{
            text-align: center;
            margin:30px;
        }
        .show{
           width: 520px;
           margin: auto;
        }
        .note{
            width: 150px;
            height: 100px;
            border: 1px solid black;
            float: left;
            margin:0 10px;
            margin-top: 50px;
        }
        .note-top{
            height:15px;
            border-bottom:1px solid black;
            text-align: right;
        }
        .note-top span{
            cursor: pointer;
        }

    </style>
<body>
    <div class="write"><input id="notetext" type="text"><button>提交</button></div>
    <div class="show">
        <div class="note">
            <div class="note-top">
            <span>X</span>
            <div class="note-text"></div>
            </div>
        </div>
    </div>
    <script>
        var notetext=document.querySelector('#notetext');
        var notes= [];
        var show=document.querySelector('.show');
        var button=document.querySelector('button');
        var i=0;
        button.onclick=function(){
            notes.push({
                id:new Date().getTime(),
                text:notetext.value
            });
            flash();
        }
        function flash(){
            show.innerHTML='';
            for(var i=0;i<notes.length;i++)
            {
                show.innerHTML+=`
                    <div class="note">
                        <div class="note-top">
                        <span onclick="closee(${i})">X</span>
                        <div class="note-text">${notes[i].text}</div>
                        </div>
                    </div>
                `;
            }
        }
        function closee(i){
            notes.splice(i,1);
            flash();
        }
    </script>
</body>
</html>